(defun mod-assistant(a b )
  (let ((i-max (max a b ))
	(i-min (min a b )))
    (if (not (zerop i-min))
	(/ (- i-max (mod i-max i-min)) i-min )))))

(defun su(a b )
  (let ((i-max (max a b ))
	(i-min  (min a b )))
    (do ((Q  0  (mod-assistant cur next))
	 (cur i-max next)
	 (next i-min (mod cur next ))
	 (u1 1 u1-next)
	 (u2 0 u2-next)
	 (u1-next 0 (- u1 (* u1-next Q)))
	 (u2-next 1 (- u2 (* u2-next Q))))
	((= next 0 ) (list cur u2-next  u1-next  Q)))))
(defun Ojld(a b)
  (let ((re (su a b)))
    (format t " ~%~2d = ~4d * ~4d + ~4d * ~4d"
	    (first re) b (second re) a (third re))))
;;同于是
(defun sam(a b)
  (let ((first-nu (mod a b))
	(per 0))
    (setq per (third (su first-nu b)))
    (when (< per 0) (+ per b) per)))

;; bei
(defun bei (a b )
  (let ((i-max (max a b ) )
	(i-min (min a b )))
    (do 
     ((next i-min (mod cur next))
     (cur i-max next))
     ((= next 0) (/ (* a b ) cur)))))

(defun su-c(a b )
  (let ((i-max (max a b ))
	(i-min  (min a b )))
    (do ((Q  0  (mod-assistant cur next))
	 (cur i-max next)
	 (next i-min (mod cur next ))
	 (u1 1 u1-next)
	 (u2 0 u2-next)
	 (u1-next 0 (- u1 (* u1-next Q)))
	 (u2-next 1 (- u2 (* u2-next Q))))
	((= next 0 ) cur))))
(defun ojld-b (&rest num)
  (reduce #'su-c `num))
 

;;su 


(defun prime-p (number)
  (loop for i from 2 to (isqrt number) never (zerop (mod number i))))
(defun find-next-prime (number)
  (loop for num from (+ 1 number) when (prime-p num) return num))



(defun find-prime (number )
  (let ((array-i (loop for i from 2 to number collect i ))
	(account 0))
    (setf array-i (remove-if-not #'prime-p array-i))
    (format t "~%")
    (setq account (length array-i))
    (if (zerop (mod (length array-i) 7))
	(format t "~{~5d  ~5d ~5d ~5d ~5d ~5d ~5d ~%~}" array-i)
	(format t "~{~5d  ~5d ~5d ~5d ~5d ~5d ~5d ~%~}" (append array-i (loop for i from 1  to (- 7 (mod (length array-i) 7)) collect 0))))
    (format nil "~%~r"  account)))  